package Demo10;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 洪汤泽大帅哥
 * Date: 2024-12-22
 * Time: 14:17
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        if (s.matches("[A-Z][a-z]{3}[0-9]{3}")){
            System.out.println(s+"合法");
        }
        else {
            System.out.println(s+"不合法");
        }
    }
}
